﻿using Bookvar.ObjectModel.Actions;

namespace Bookvar.ServiceModel
{
    /// <summary>
    /// Interface for the action service. An action service responsibility is to execute all actions. It should
    /// store them for undo/redo operations.
    /// All actions should be executed through the IActionService, so it can support undo/redo and the other
    /// functionalities of the different implementers.
    /// </summary>
    public interface IActionService
    {
        /// <summary>
        /// Gets a value indicating whether this action service supports undo.
        /// </summary>
        /// <value><c>true</c> if this action service can undo; otherwise, <c>false</c>.</value>
        bool CanUndo { get; }

        /// <summary>
        /// Gets a value indicating whether this action service supports redo operations.
        /// </summary>
        /// <value><c>true</c> if this action service supports redo; otherwise, <c>false</c>.</value>
        bool CanRedo { get; }

        /// <summary>
        /// Gets a value indicating whether this action service has an action to undo.
        /// This is true when any action that can be undo-ed is executed and the action service
        /// supports undo operations.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this action service has an action to undo; otherwise, <c>false</c>.
        /// </value>
        bool HasActionToUndo { get; }

        /// <summary>
        /// Gets a value indicating whether this action service has an action to redo.
        /// This is true when at least one action is undone and the action service supports redo.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this action service has an action to redo; otherwise, <c>false</c>.
        /// </value>
        bool HasActionToRedo { get; }

        /// <summary>
        /// Redoes the last undone action.
        /// </summary>
        void Redo();

        /// <summary>
        /// Undoes the last executed action.
        /// </summary>
        void Undo();

        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="action">The action to be executed.</param>
        void Execute( IAction action );
    }
}
